package com.ruoyi.web.settlestyle.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.web.utils.ManualPagination;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.settlestyle.domain.Settlestyle;
import com.ruoyi.web.settlestyle.service.ISettlestyleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * settlestyleController
 * 
 * @author ruoyi
 * @date 2024-09-26
 */
@RestController
@RequestMapping("/settlestyle/settlestyle")
public class SettlestyleController extends BaseController
{
    @Autowired
    private ISettlestyleService settlestyleService;

    /**
     * 查询settlestyle列表
     */
    @PreAuthorize("@ss.hasPermi('settlestyle:settlestyle:list')")
    @GetMapping("/list")
    public TableDataInfo list(Settlestyle settlestyle)
    {
//        startPage();
        List<Settlestyle> list = settlestyleService.selectSettlestyleList(settlestyle);
        return ManualPagination.pagination(list);
    }

    /**
     * 导出settlestyle列表
     */
    @PreAuthorize("@ss.hasPermi('settlestyle:settlestyle:export')")
    @Log(title = "settlestyle", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Settlestyle settlestyle)
    {
        List<Settlestyle> list = settlestyleService.selectSettlestyleList(settlestyle);
        ExcelUtil<Settlestyle> util = new ExcelUtil<Settlestyle>(Settlestyle.class);
        util.exportExcel(response, list, "settlestyle数据");
    }

    /**
     * 获取settlestyle详细信息
     */
    @PreAuthorize("@ss.hasPermi('settlestyle:settlestyle:query')")
    @GetMapping(value = "/{cSSCode}")
    public AjaxResult getInfo(@PathVariable("cSSCode") String cSSCode)
    {
        return success(settlestyleService.selectSettlestyleByCSSCode(cSSCode));
    }

    /**
     * 新增settlestyle
     */
    @PreAuthorize("@ss.hasPermi('settlestyle:settlestyle:add')")
    @Log(title = "settlestyle", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Settlestyle settlestyle)
    {
        return toAjax(settlestyleService.insertSettlestyle(settlestyle));
    }

    /**
     * 修改settlestyle
     */
    @PreAuthorize("@ss.hasPermi('settlestyle:settlestyle:edit')")
    @Log(title = "settlestyle", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Settlestyle settlestyle)
    {
        return toAjax(settlestyleService.updateSettlestyle(settlestyle));
    }

    /**
     * 删除settlestyle
     */
    @PreAuthorize("@ss.hasPermi('settlestyle:settlestyle:remove')")
    @Log(title = "settlestyle", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cSSCodes}")
    public AjaxResult remove(@PathVariable String[] cSSCodes)
    {
        return toAjax(settlestyleService.deleteSettlestyleByCSSCodes(cSSCodes));
    }
}
